﻿$(document).ready(function () {
    var light = $("#J_light");
    var J_item = $("#J_activity_get");
    var J_light_title = $("#J_light_title");
    var J_light_body = $("#J_light_body");

    J_item.click(function () {
        //exec
        var t = $(this);
        var url = t.attr("data-action");
        var data = {};
        $.ajax({
            async: true,
            type: "post",
            url: url,
            data: data,
            dataType: "text",
            success: function (msg) {
                var data = eval("(" + msg + ")");
                var status = data["status"];
                var award = data["award"];
                if (status == "1") {
                    light.find(".message").removeClass("error").addClass("success");
                    J_light_title.html("恭喜您！");
                    J_light_body.html("中得<span>" + award + "</span>，我们将在您中奖后的1~7个工作日内，将奖品发放到您的盛大通行证中。");
                } else {
                    light.find(".message").removeClass("success").addClass("error");
                    J_light_title.html("对不起！");
                    J_light_body.html("奖品已经领完，请下次活动再参加。");
                };
                light.show();
                light.find(".light-bg").css("height", $(document).height());
                light.find(".light-box").css({ left: (J_item.offset().left - 450), top: t.offset().top - 100 });
                light.find(".light-iframe").css("height", $(document).height());
                return false;
            },
            error: function () {
                alert("抱歉，出错了！请刷新页面后再试。");
                return false;
            }
        });
        return false;
    });
    //提示关闭
    $("#J_light_btn").click(function () {
        light.hide();
    });

});